﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using FancyBattles.GameAudio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace FancyBattles.GameScreen
{
    class TutorialScreen : GameScreen
    {
        #region Atributes

        private MenuEntry nextScreen;

        public static LinkedList<Texture2D> tutorialScreens;
        public static Texture2D currentScreen;
        private Texture2D firstTutorial;
        private Texture2D secondTutorial;
        private Texture2D thirdTutorial;
        private Texture2D tutorialBG;

        #endregion

        #region Properties
        #endregion

        #region Creators
        public TutorialScreen()
        {
            tutorialScreens = new LinkedList<Texture2D>();
        }
        #endregion

        #region Methods

        public override void LoadContent()
        {
            base.LoadContent();

            //AudioManager.PlayMusicLoop("explosion");

            firstTutorial = ContentManager.Load<Texture2D>("Screens/TUTORIAL_1");
            secondTutorial = ContentManager.Load<Texture2D>("Screens/TUTORIAL_2");
            thirdTutorial = ContentManager.Load<Texture2D>("Screens/TUTORIAL_3");
            tutorialBG = ContentManager.Load<Texture2D>("Screens/BACKGROUND");

            tutorialScreens.AddLast(firstTutorial);
            tutorialScreens.AddLast(secondTutorial);
            tutorialScreens.AddLast(thirdTutorial);
            currentScreen = firstTutorial;
        }

        public override void UnloadContent()
        {
            base.UnloadContent();
        }

        public override UpdateResponse Update(GameTime gameTime)
        {
            UpdateResponse updateAnswer = UpdateResponse.ERROR;
            if (InputHandler.isConfirm(PlayerIndex.One))
            {
                if (currentScreen == thirdTutorial)
                {
                    updateAnswer = UpdateResponse.CLOSE_SCREEN;
                }
                else
                {
                    currentScreen = tutorialScreens.Find(currentScreen).Next.Value;
                }
            }
            return updateAnswer;
        }

        public override void Draw(GameTime gameTime)
        {
            Color nextScreenColor = Color.Red;

            Rectangle fullscreen = new Rectangle(0, 0, 1280, 720);

            SpriteBatch.Begin();

            SpriteBatch.Draw(tutorialBG, fullscreen, Color.White);
            SpriteBatch.Draw(currentScreen, fullscreen, Color.White);

            SpriteBatch.End();
            base.Draw(gameTime);
        }

        #endregion
    }
}
